function debug(str){
	if(typeof console != undefined){
		console.log.apply(console, arguments);
	} else {
		alert(str);
	}
}

(function(){
	var EventCenter = function(){
		this._e = {};
	};
	$.extend( EventCenter.prototype, {
		on: function(evtName, handler){
			this._e[evtName] = this._e[evtName] || {};
			this._e[evtName][handler] = handler;
		},
		off: function(evtName, handler){
			if(handler){
				delete this._e[evtName][handler];
			} else {
				delete this._e[evtName];
			}
		},
		fire: function(evtName, data){
			var evts = this._e[evtName] || {};

			debug(evtName, data);

			for(var hdl in evts ){
				var fn = evts[hdl];
				if(typeof fn == 'function' &&  fn(data) === 'break'){
					return false;
				};
			}
		}
	});
	//全局事件中心
	window.EC = new EventCenter();


	function addDyncClass(){
		//鼠标hover的样式
		$('[hover-class]').live('mouseenter', function(){
			$(this).addClass($(this).attr('hover-class'));
		}).live('mouseleave', function(){
			$(this).removeClass($(this).attr('hover-class'));
		});

		//点击样式,比如三态按钮
		$('[click-class]').live('mousedown', function(){
			$(this).addClass($(this).attr('click-class'));
		}).live('mouseup', function(){
			$(this).removeClass($(this).attr('click-class'));
		}).live('mouseleave', function(){
			$(this).removeClass($(this).attr('click-class'));
		});
	}
	addDyncClass();
})();